package com.gxc.config;

import com.gxc.filter.TimeFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * @author GongXincheng
 * @since 2019-10-12 20:07
 */
@Configuration
public class FilterConfiguration {

    @Bean
    public TimeFilter timeFilter() {
        return new TimeFilter();
    }

    @Bean
    public FilterRegistrationBean<Filter> timeFilterRegistration() {
        FilterRegistrationBean<Filter> register = new FilterRegistrationBean<>();
        register.setFilter(timeFilter());
        register.addUrlPatterns("/*");
        register.setName("TimeFilter");
        register.setOrder(1);
        return register;
    }

}
